package com.lei.zjs.web.action;

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.lei.zjs.service.ebi.RoleService;
import com.lei.zjs.vo.Role;
import com.lei.zjs.web.action.base.BaseAction;

/**
 * 角色管理Action
 * @author Spinacia
 *
 */
@Controller
@Scope("prototype")
public class RoleAction extends BaseAction<Role>{

	@Resource
	private RoleService roleService;
	
	private String functionIds;
	
	public void setFunctionIds(String functionIds) {
		this.functionIds = functionIds;
	}

	//保存角色信息
	public String save(){
		roleService.save(model,functionIds);
		return "list";
	}
	
	//查询所有角色信息
	public String list() throws IOException{
		List<Role> list = roleService.findAll();
		String[] excludes = new String[]{"functions","users"};
		this.writeJsonArray2String(list, excludes );
		return NONE;
	}
}
